<% 
'' This code is absolute freeware. you can do with it as you please. 
'' There are no restrictions what so ever, but the code is AS IS, no warrenty or liabilty
'' Please leave these commentlines intact
'' Netherlands, February 2004
'' M.Blokdijk
'' maarten@blokdijk.com
'' V 1.0

incFile "admin/moduli/content/fm_include.asp" 

Dim fs, sAction, sFile, sPath, sFolder, sFileType, scriptname, dbfile, ReadStream, WriteStream, WriteFile, fileobject, filecollection, file, startpath, lineid, bgcolor, bgcolor_on, bgcolor_off, foldercollection, folder, errornum, errorcode

' Reset our errorcode values 
errornum = 0
errorcode = ""



scriptname="admin.asp?modulo=content&amp;op=filemanager"
sAction = Request.Querystring("action")
sFileType = Request.Querystring("filetype")

If Request("path") = "" Then

''setting the base path or rootfolder
''*****************************************************
 sPath = session("SYSTEM_PATH_IMG")''the root folder for this sytem.
''*****************************************************

response.Write sPath

if isADM(session("uID"), "content") or isMOD(session("uID"), "content") then
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
		if not fso.FolderExists(Server.MapPath(session("SYSTEM_PATH_IMG"))) then
			fso.CreateFolder(Server.MapPath(session("SYSTEM_PATH_IMG")))	
		end if
	Set fso = Nothing
end if

Else
 'Controllo se si sta erroneamente risalendo di cartelle
 sPath = Request("path")
 If InStr(sPath,"../") Then
	errornum = 2
 End If
 'Controllo che la path sia subpath dell'utente attuale
 if left(sPath, len(session("SYSTEM_PATH_IMG"))) <> session("SYSTEM_PATH_IMG") then
 	errornum = 2
 end if


	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	if fso.FolderExists(Server.MapPath(session("SYSTEM_PATH_IMG"))) then
		if not fso.FolderExists(Server.MapPath(sPath)) then
			errornum = 1
		end if
	else
		errornum = 3
	end if
	Set fso = Nothing
	
End If
If sPath="/" Then
 If Request.Querystring("file") = "" Then
  sFile = sPath & Request.Form("file")
 Else
  sFile = sPath & Request.Querystring("file")
 End If 
 If Request.Querystring("folder") = "" Then
  sFolder = sPath & Request.Form("folder")
 Else
  sFolder = sPath & Request.Querystring("folder")
 End If
Else
 If Request.Querystring("file") = "" Then
  sFile = sPath & "/" & Request.Form("file")
 Else
  sFile = sPath & "/" & Request.Querystring("file")
 End If
 If Request.Querystring("folder") = "" Then
  sFolder = sPath & "/" & Request.Form("folder")
 Else
  sFolder = sPath & "/" & Request.Querystring("folder")
 End If
End If
session("foldername")=spath
' Make sure that no errors have occurred and no illegal actions have been taken before doing our stuff... 
If errornum < 1 Then
  Set fs = Server.CreateObject("Scripting.FileSystemObject")

  Select Case sAction

    Case "savefile"
      SaveFile

    Case "viewfolder"
      Showlist

    Case "newfile"
      CreateFile

    Case "newfolder"
      CreateFolder

    Case "deletefile"
      DeleteFile

    Case "deletefolder"
      DeleteFolder
	
	Case "CreateNewFolder"
	  CreateNewFolder
	
	Case "UploadFiles"
		UploadFiles
		
	Case "RenameFolder"
		RenameFolder

	Case "RenameFile"
		RenameFile

	Case "nospace"
		nospace
		
    Case Else
      Showlist 
  End Select
  Set fs = Nothing
Else
  DisplayErrors
End If
%>


